package cn.tedu.review;

import com.sun.media.jfxmediaimpl.HostUtils;

import java.util.Arrays;

/*本类用于副词S投入哪个的常用API*/
public class TestString2 {
    public static void main(String[] args) {
        String  s1 = "abc";

        System.out.println(s1.length());//字符串长度
        System.out.println(s1.toUpperCase());//全大写
        System.out.println(s1.toLowerCase());//全小写
        System.out.println(s1.startsWith("c"));//字符开头
        System.out.println(s1.endsWith("c"));//字符结尾
//        System.out.println(s1.charAt(4));//会报错,数组下标越界
        System.out.println(s1.charAt(0));

        String s2= "abcfgjcbba";
        System.out.println(s2.length());//
        System.out.println(s2.indexOf("b"));//第一次出现的下标
        System.out.println(s2.lastIndexOf("b"));//最后一次出现的下标
        System.out.println(s1.concat("yyy"));//拼接字符串但不改变原字符串
        System.out.println(s1);

        String s3 = "   ghuh  j  ";
        System.out.println(s3.trim());

        String s4 = "abcdefgh";
        System.out.println(s4.substring(2));//cdefgh,范围下标2到结尾
        System.out.println(s4.substring(2,6));//cdef,


        System.out.println(String.valueOf(10)+10);//将int类型值转换为String类型
        System.out.println("10"+10);
        System.out.println(10+10);

        byte[] bs = s1.getBytes();
        System.out.println(Arrays.toString(bs));

        String s5  ="a b c d e";
        String[] s = s5.split(" ");//分隔符
        System.out.println(Arrays.toString(s));


    }
}
